<?php
$box_title= "Add/Edit Messages";
$box_contents = "";

$id = @$_GET['id'];
$message = @trim($_POST['message']);

if(!empty($message)) {
    if(empty($id)) {
        sql_query("INSERT INTO messages(message) values('".$message."');");
    } else {
        sql_query("UPDATE messages SET message='".$message."' WHERE id='$id';");
    }
    echo "<script> window.location='index.php?m=messages'; </script>";
} else {
    $box_contents .= "<div class=\"highlight\">Error: Message must not be empty</div>";
}
?>